{% extends "../layouts/admin.html" %} {% block content %}
<header class="header navbar bg-white shadow">
	<div class="btn-group tool-button">
		<a class="btn btn-primary navbar-btn" href="/store/attribute/index" data-pjax><i class="ti-angle-left"></i> 返回</a>
	</div>
</header>

<div class="content-wrap">
	<div class="wrapper" style="min-height:500px;">
		<section class="panel panel-form">
			<form id="addForm" role="form" class="form-horizontal parsley-form" data-parsley-validate action="/store/attribute/add" method="post">
				<div class="row mb10">
					<div class="col-lg-12">
						<div class="form-group">
							<label for="name" class="col-sm-2 control-label">属性名称</label>

							<div class="col-sm-8">
								<input type="text" id="name" class="form-control" name="name" data-parsley-required="true" placeholder="商品属性名称">
							</div>
						</div>
						<div class="form-group">
							<label for="name" class="col-sm-2 control-label">商品类型</label>

							<div class="col-sm-8">
								<input type="text" id="typeName" class="form-control" name="typeName" data-parsley-required="true" placeholder="选择商品类型">
								<input type="text" id="type" name="type"  hidden>
							</div>
						</div>
						<div class="form-group">
							<label for="code" class="col-sm-2 control-label">录入方式</label>

							<div class="col-sm-8">
								<select name="input_type" id="input_type" class="form-control">
									{% for index,item in config.setup.attributeInputType %}
									<option value="{{index}}">{{item}}</option>
									{% endfor%}
								</select>
							</div>
						</div>
						<div class="form-group" style="display: none;">
							<label for="values" class="col-sm-2 control-label">可选值</label>

							<div class="col-sm-8">
								<textarea id="values" class="form-control" name="values" rows="3"   placeholder="多个可选值，用','号隔开"></textarea>
								
							</div>
						</div>
						

						
						
						
					</div>
				</div>
				<div class="col-lg-3"></div>
				<div class="col-lg-6">
					<div class="form-group text-center">
						<label></label>

						<div>
							<button class="btn btn-primary btn-block btn-lg btn-parsley" data-loading-text="正在提交...">提 交</button>
						</div>
					</div>
				</div>
			</form>
		</section>

	</div>
</div>
<div id="dialogSelect" class="modal fade bs-modal-sm" tabindex="-3" role="dialog" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">

    </div>
  </div>
</div>
<script language="JavaScript">
	$("#input_type").change(function(){
		if($(this).val() == 2){
			$(this).parents(".form-group").next().show();
		}else{
			$(this).parents(".form-group").next().hide();
		}
	});
	$(document).ready(function() {
		
		$('#addForm').ajaxForm({
			dataType: 'json',
			beforeSubmit: function(arr, form, options) {
				form.find("button:submit").button("loading");
			},
			success: function(data, statusText, xhr, form) {
				if(data.errno == 0) {
					Toast.success(data.data);
					//刷新父级菜单
					//form.resetForm();
				} else {
					Toast.error(data.errmsg);
				}
				form.find("button:submit").button("reset");
			}
		});
		
		
		
	});
	
	 $("#dialogSelect").on("hidden.bs.modal", function () {
      $(this).removeData("bs.modal");
    });
    $("#typeName").on("click", function () {
      
      $("#dialogSelect").modal({
        remote: "/store/type/select"
      });
    });
</script>
{% endblock %}